from django.shortcuts import render
from django.http import HttpResponse
import json
import sqlite3

# Create your views here.
from .models import Department

def departments(request):
    cx = sqlite3.connect('db.sqlite3')
    cu = cx.cursor()
    cu.execute('SELECT department FROM registration_department')
    data = cu.fetchall()
    return HttpResponse(json.dumps(data), content_type='application/json')

def terminals(request):
    cx = sqlite3.connect('db.sqlite3')
    cu = cx.cursor()
    cu.execute('SELECT IP,address FROM registration_terminal')
    data = cu.fetchall()
    return HttpResponse(json.dumps(data), content_type='application/json')